import numpy as np
from digital_freq import digital_freq


def lowpass_filter(Signal, channel_spacing_Hz):
    """
    Generate a low-pass filter similar to the MATLAB Lowpass_filter function.

    Parameters:
    Sampling_num: The number of samples.
    cut_off: The cutoff frequency of the filter.
    Sampling_rate: The sampling rate.

    Returns:
    h: The low-pass filter array.
    """
    # Generate the digital frequency array

    cut_off = channel_spacing_Hz
    Sampling_num = Signal['Sampling_num']

    f = digital_freq(Signal)

    # Create the lowpass filter
    h = np.ones(Sampling_num, dtype=np.complex64)
    h[f > cut_off] = 0
    h[f < -cut_off] = 0

    return h
